package com.xjrsoft.module.demo.controller;


import com.aliyun.alimt20181012.models.TranslateGeneralResponse;
import com.aliyun.tea.TeaException;
import com.xjrsoft.common.result.Response;
import com.xjrsoft.core.tool.utils.BeanUtil;
//import com.xjrsoft.module.demo.rabbitmq.MyRabbitMQProvide;
import com.xjrsoft.core.tool.utils.TranslateUtil;
import com.xjrsoft.core.tool.utils.aiplm.AiplmModelsEntiy;
import com.xjrsoft.core.tool.utils.aiplm.AiplmTxt2imgParam;
import com.xjrsoft.core.tool.utils.aiplm.AiplmTxt2imgResult;
import com.xjrsoft.core.tool.utils.aiplm.AiplmUtil;
import com.xjrsoft.module.demo.rabbitmq.MyRabbitMQProvide;
import com.xjrsoft.module.demo.service.IXjrBaseItemService;
import com.xjrsoft.module.demo.vo.ItemVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.ibatis.javassist.tools.reflect.Sample;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2021-04-09
 */
@RestController
@AllArgsConstructor
@RequestMapping("/item")
@Api(value = "/item", tags = "商品模块")
public class XjrBaseItemController {

    private final IXjrBaseItemService itemService;

    private MyRabbitMQProvide myRabbitMQProvide;

    @GetMapping
    @ApiOperation(value = "获取商品列表")
    public Response<List<ItemVo>> getList(){
        return Response.ok(BeanUtil.copyList(itemService.list(), ItemVo.class));
    }

    @GetMapping("rabbitmq-Provide")
    @ApiOperation(value = "rabbitmq")
    public Response<Boolean> testRabbitMQProvide(){
        myRabbitMQProvide.testProvider();
        return Response.ok(true);
    }

    @GetMapping("/test")
    @ApiOperation(value = "rabbitmq")
    public Response<AiplmTxt2imgResult> test(@RequestParam("text") String text) throws Exception {
        AiplmTxt2imgParam param = new AiplmTxt2imgParam("LEOSAM FilmGirl Ultra 写实大模型_FilmGirl Ultra.safetensors [b363551a70]");
        param.setBatch_size(1);
        param.setCfg_scale(7);
        param.setNegative_prompt("NSFW");
        param.setPrompt("full body,  a  girl,  blue hand, Long yellow hair,   blue shoes, write background,  <lora:20240320-1710939437372:1>");
        param.setSampler_index("DPM++ SDE Karras");
        param.setSeed(-1);
        param.setSteps(20);
        param.setWidth(512);
        param.setHeight(512);
        return Response.ok(AiplmUtil.txt2img(param));
    }

}
